#!/usr/bin/env python
# -*- coding: utf-8 -*-
# title       :
# author      : jarry

import sys
import os
import logging
from SceneCheckTool.checkScript.CheckBase import CheckBase

try:
    import maya.cmds as cmds
    import pymel.core as pm
except:
    pass
import jarryLibs.mayakit.MayaUtils as mu
reload(mu)

logging.basicConfig()
log = logging.getLogger(__name__)
log.setLevel(logging.DEBUG)


class CheckRenderSize(CheckBase):
    def __init__(self):
        super(CheckRenderSize, self).__init__()
        pass

    def check(self):
        w, h = mu.getRenderSize()

        if w != 2048 or h != 858:
            result_log = u'Error:渲染尺寸不正确，当前为%sx%s\n' % (w, h)
        else:
            result_log = u'Succeed:没有问题\n'
        return result_log
    
    def fix(self):
        w, h = mu.getRenderSize()
        if w != 2048 or h != 858:
            try:
                mu.setRenderSize(2048, 858)
                result_log = u'Succeed:渲染尺寸设置成功!\n'
                log.info(result_log)
                return result_log
            except:
                result_log = u'Error:渲染尺寸设置失败\n'
                log.error(result_log)
                return result_log
        else:
            return u'Succeed:没有问题\n'
